Programming for Data Science¶

NumPy- Eigen Values & Eigen Vectors¶

Dr. Bhargavi R

SCOPE, VIT Chennai

Eigen Values & Eigen Vectors¶

  • Eigen is a German word meaning “characteristic”
  • Eigen vector is also called as Characteristic vector
  • Eigen vector of a linear transformation is a nonzero vector that changes at most by a scalar factor when that linear transformation is applied to it.
  • The corresponding eigenvalue is the factor by which the eigenvector is scaled.
  • Consider a small sqare centered at origin
  • It has number of vectors Figure
  • Now let us apply the transformation of vertical scaling and see the distortion in the shape.

Figure

  • We can observe that few vectors undergo a transformation and few do not.
  • Same way if we apply horizontal transformation, then few vectors will not undergo any transformation
  • Now look the following shear transformation

Figure

  • You can observe that the vector colored in blue is not undergoing any transformation
  • Let's now focus just on three vectors and see the how these vectors transform Figure
  • Apply vertical scaling (By a factor of 2) and see the transformation

Figure

  • Only Green color vector does not change either in direction or magnitude
  • Pink colored one does not change it\'s direction (i.e it is in the same span), but the size is doubled
  • These hrizontal and vertical vectors which do not change their span are the characteristic of this transoformation
  • These charcteristic vectors are called as Eigen vectors.
  • The value by which a vector has scaled is called as its eigen value
  • In this example Eigen value of Horizontal vector is 1
  • Eigen value of vertical vector is 2
  • Let us now apply pure shear transformation on the sqare and see the tranformation

Figure

  • Which is the Eigen vector here ?
  • Horizontal vector.
  • Apply pure rotation now

Figure

  • As you can see this transformation does not have any Eigen vectors
In [1]:
import numpy as np
import numpy.linalg as lg
In [2]:
# Find the eigen vectors and eigen values of the matrix [[3, -2], [1,  0]]

X = np.array([[3, -2], [1,  0]])
val = lg.eigvals(X)
print(val)

val, vect = lg.eig(X)
print("Eigen Values are", val)
print("vectors are", vect)
[2. 1.]
Eigen Values are [2. 1.]
vectors are [[0.89442719 0.70710678]
 [0.4472136  0.70710678]]